package acm.pta7;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class T1 {
    public static void main(String[] args) {
        Reader sc=new Reader();
        int n = sc.nextInt();
        int[][][] arr=new int[n][][];
        int max=0;
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            arr[i]=new int[k][10];
            max=Math.max(max,k);
        }
        int rest=n;
        int id=0;
        int lastShcool=1;
        int last=0;
        for (int i = 0; i < max; i++) { //所剩的批次 //所剩学校
            for (int z = 0; z < 10; z++) {
                for (int j = 0; j < arr.length; j++) {
                    if (i<arr[j].length){
                        if (lastShcool==j){
                            id+=2;
                        }else {
                            id+=1;
                        }
                        arr[j][i][z]=id;
                        lastShcool=j;
                    }
                }
            }
        }

        for (int i = 0; i < arr.length; i++) {
            System.out.println("#"+(i+1));
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < arr[i].length; j++) {
                for (int k = 0; k < arr[i][j].length; k++) {
                    sb.append(arr[i][j][k]).append(" ");
                }
                sb.replace(sb.length()-1,sb.length(),"\n");
            }
            System.out.print(sb);
        }
    }
    static class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

}
